package com.iam;

import com.iam.config.CORSFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import javax.servlet.Filter;

/**
 * 权限认证服务
 * 不需要和其他服务有太多的关联
 */
@SpringBootApplication
@MapperScan("com.iam.mapper")
@EnableAspectJAutoProxy
public class IamApplication {

    public static void main(String[] args) {
        SpringApplication.run(IamApplication.class, args);

    }

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        // 使用注入对象的方式
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new CORSFilter());
        filterRegistrationBean.setName("corsFilter");
        filterRegistrationBean.addUrlPatterns("/com/iam");
        return filterRegistrationBean;
    }
}
